<template>
  <div class="dataCustomization-dataCustomization">
      <div class="row_item">
          <div class="float_left width_100px">需求标题：</div>
          <div class="margin_left_100">
              <input type="text" v-model="CRTitle" class="form-control width_200px" placeholder="需求标题">
          </div>
      </div>

      <div class="row_item">
          <div class="float_left width_100px">参考网站：</div>
          <div class="margin_left_100">
              <textarea id="textarea-input" v-model="CRWebsite" rows="9" class="form-control" placeholder="请输入参考网站.."></textarea>
          </div>
      </div>

      <div class="row_item">
          <div class="float_left width_100px">预算金额：</div>
          <div class="margin_left_100">
              <input type="text" v-model="CRMoney" class="form-control width_200px" placeholder="预算金额">
          </div>
      </div>

      <div class="row_item">
          <div class="float_left width_100px">联系QQ：</div>
          <div class="margin_left_100">
              <input type="text" v-model="CRQQ" class="form-control width_200px" placeholder="联系QQ">
          </div>
      </div>

      <div class="row_item">
          <div class="float_left width_100px">手机号码：</div>
          <div class="margin_left_100">
              <input type="text" v-model="CRMobile" class="form-control width_200px" placeholder="手机号码">
          </div>
      </div>

      <div class="row_item">
          <div class="float_left width_100px">手机验证码：</div>
          <div class="margin_left_100">
              <input type="text" v-model="code" class="form-control width_200px" style="display: inline-block;" placeholder="手机验证码">
              <button type="button" @click="getYZM" class="btn btn-primary">获取验证码</button>
          </div>
      </div>

        <div class="row_item width_50 margin_center">
            <button type="button" @click="addAction" class="btn btn-primary btn-lg btn-block">提交</button>
        </div>
  </div>
</template>

<script>

    import _ from "lodash"
    // 发送ajax 请求的组件
    import getData from '../../api/getData'

export default {
  data: function () {
      return {
          CRTitle: "",
          CRWebsite: "",
          CRMoney: "",
          CRQQ: "",
          // 手机验证码
          code: "",
          CRMobile: ""
      };
  },
  methods: {
      // 添加动作
      addAction: function(){
          if(this.CRTitle == ""){
              this.$Message.warning({
                  content: '请输入需求标题',
                  duration: 5,
                  closable: true
              });
              return false;
          }
          if(this.CRWebsite == ""){
              this.$Message.warning({
                  content: '请输入参考网站',
                  duration: 5,
                  closable: true
              });
              return false;
          }
          if(this.CRMoney == ""){
              this.$Message.warning({
                  content: '请输入预算金额',
                  duration: 5,
                  closable: true
              });
              return false;
          }
          if(this.CRQQ == ""){
              this.$Message.warning({
                  content: '请输入联系QQ',
                  duration: 5,
                  closable: true
              });
              return false;
          }
          if(this.code == ""){
              this.$Message.warning({
                  content: '请输入验证码',
                  duration: 5,
                  closable: true
              });
              return false;
          }
          if(this.CRMobile == ""){
              this.$Message.warning({
                  content: '请输入手机号码',
                  duration: 5,
                  closable: true
              });
              return false;
          }
          var that = this;
          var paramObj = {
              CRTitle: that.CRTitle,
              CRWebsite: that.CRWebsite,
              CRMoney: that.CRMoney,
              CRQQ: that.CRQQ,
              code: that.code,
              CRMobile: that.CRMobile
          };

          getData.post("insertCustomizeRecords_CustomizeRecord",paramObj).then(function (response) {
              var tempData = response.data.data;
              console.log("JSON.stringify(tempData) : " + JSON.stringify(tempData));
          })
          .catch(function (response) {
              console.log(response);
          });

      },
      // 获取验证码
      getYZM: function () {
          var that = this;
          var paramObj = {
              phone: that.CRMobile
          };
          getData.post("getYZM_CustomizeRecord",paramObj).then(function (response) {
              var tempData = response.data.data;
              console.log("JSON.stringify(tempData) : " + JSON.stringify(tempData));
          })
              .catch(function (response) {
                  console.log(response);
              });
      }
  },
  components: {
  }
}
</script>

<style scoped lang="scss">
    .dataCustomization-dataCustomization{
        .row_item{
            margin-top: 14px;
        }
    }

</style>
